﻿ComparisonTests = function () {
    this.Name = "Comparison Tests";
};

ComparisonTests.prototype = new TestFixture();


ComparisonTests.prototype.TestCompare = function () {
    var vm = new VM();
    vm.Execute("ldc.i4 4");
    vm.Execute("ldc.i4 4");
    vm.Execute("ceq");
    var result = vm.State.Stack.Top();
    this.Assert(1, result.Value);
};

ComparisonTests.prototype.TestCompareFalse = function () {
    var vm = new VM();
    vm.Execute("ldc.i4 4");
    vm.Execute("ldc.i4 5");
    vm.Execute("ceq");
    var result = vm.State.Stack.Top();
    this.Assert(0, result.Value);
};

ComparisonTests.prototype.TestCompareLT = function () {
    var vm = new VM();
    vm.Execute("ldc.i4 4");
    vm.Execute("ldc.i4 5");
    vm.Execute("clt");
    var result = vm.State.Stack.Top();
    this.Assert(1, result.Value);
};

ComparisonTests.prototype.TestCompareLTFalse = function () {
    var vm = new VM();
    vm.Execute("ldc.i4 4");
    vm.Execute("ldc.i4 3");
    vm.Execute("clt");
    var result = vm.State.Stack.Top();
    this.Assert(0, result.Value);
};

ComparisonTests.prototype.TestCompareGT = function () {
    var vm = new VM();
    vm.Execute("ldc.i4 5");
    vm.Execute("ldc.i4 4");
    vm.Execute("cgt");
    var result = vm.State.Stack.Top();
    this.Assert(1, result.Value);
};

ComparisonTests.prototype.TestCompareGTFalse = function () {
    var vm = new VM();
    vm.Execute("ldc.i4 5");
    vm.Execute("ldc.i4 6");
    vm.Execute("cgt");
    var result = vm.State.Stack.Top();
    this.Assert(0, result.Value);
};
